package com.mop.sg2;

import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.mop.sg2.layer.LayerManager;
import com.mop.sg2.map.LevelUp;
import com.mop.sg2.map.MyView;
import com.mop.sg2.map.TestMap;
import com.mop.test.TestNet;

public class Sg2Activity extends Activity implements View.OnTouchListener,
		View.OnKeyListener {
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 全屏
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
//		try {
//			TestMap.initTestMap(this.getResources());
//			
//			LevelUp.initBitmap(this.getResources());// 初始化图片资源
//			
//			LayerManager.initLayer(this);
//
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		
//		//客户端启动
//		Client.getInstance().start();
//		//测试线程启动
//		TestNet t=new TestNet();
//		t.start();
	}

	@Override
	public boolean onTouch(View arg0, MotionEvent arg1) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onKey(View v, int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		switch (keyCode) {
		case KeyEvent.KEYCODE_DPAD_DOWN:// 向下
			MyView.y += 5;
			break;
		case KeyEvent.KEYCODE_DPAD_UP:// 向上
			MyView.y -= 5;
			break;
		case KeyEvent.KEYCODE_DPAD_LEFT:// 向左
			MyView.x -= 5;
			break;
		case KeyEvent.KEYCODE_DPAD_RIGHT:// 向右
			MyView.x += 5;
			break;
		default:
			break;
		}
		return super.onKeyDown(keyCode, event);
	}
}